<extend name="Public::innerbase"/>
<block name="content">
    <div class="page-header">
        <h3>角色管理</h3>
    </div>
	<form class="form-inline" style="margin-bottom:10px;">
		<a class="btn btn-success" href="{:U('role_edit')}">新 增</a>
	</form>
	<form class="ids">
		<table class="table wm-table-bordered table-striped table-hover">
			<thead>
				<tr>
					<th>角色名</th>
					<th>备注</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
			<notempty name="list">
			<volist name="list" id="vo">
				<tr>
					<td>
						<a href="{:U('role_edit?id='.$vo['id'])}">{$vo.name}</a>
					</td>
					<td>{$vo.remark}</td>
					<td><if condition="$vo['status'] eq 0">禁用<else/>启用</if></td>
					<td>
						<a title="编辑" href="{:U('role_edit?id='.$vo['id'])}">编辑</a>
						<a title="授权" href="{:U('role_access?id='.$vo['id'])}">授权</a>
						<a class="confirm" title="删除" href="{:U('role_delete?id='.$vo['id'])}">删除</a>
					</td>
				</tr>
			</volist>
			<else/>
			<td colspan="10" class="text-center"> aOh! 暂时还没有内容! </td>
			</notempty>
			</tbody>
		</table>
	</form>
	<!-- 分页 -->
	<div class="page">
		{$page}
	</div>
</block>

<block name="script">
    <script type="text/javascript">
        $(function() {
            //搜索功能
            $("#search").click(function() {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function(e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
            //导航高亮
            $('.side-sub-vo').find('a[href="{:U('index')}"]').closest('li').addClass('current');
            //点击排序
        	$('.list_sort').click(function(){
        		var url = $(this).attr('url');
        		var ids = $('.ids:checked');
        		var param = '';
        		if(ids.length > 0){
        			var str = new Array();
        			ids.each(function(){
        				str.push($(this).val());
        			});
        			param = str.join(',');
        		}

        		if(url != undefined && url != ''){
        			window.location.href = url + '/ids/' + param;
        		}
        	});
        });
    </script>
</block>